package server;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.FileInputStream;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.adobe.acrobat.Viewer;

public class PDFViewer extends JPanel
{
	private Viewer view;
	
  public PDFViewer( String filename )
  {
    // Set the layout for this panel
    this.setLayout( new BorderLayout() );

    // Create the viewer
    try
    {
      FileInputStream fis = new FileInputStream( filename );
      view = new Viewer();
      view.setDocumentInputStream( fis );
      this.add( view, BorderLayout.CENTER );
      view.activate();
      
      // Create our frame
      JFrame frame = new JFrame( "PDF Viewer" );
      frame.setSize( 1024, 768 );
      Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
      frame.setLocation( d.width/2 - 512, d.height/2 - 384 );
      frame.getContentPane().add(this);
      frame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
      frame.setVisible( true );
    }
    catch( Exception e )
    {
      e.printStackTrace();
    }
  }
}